/*
 * Filename    : Graphic_Load.java
 * Projectname : Sound Of Indonesia
 * Date        : Nov 1, 2012 , 2:08:50 PM 
 * 
 * PratamaNurWijaya
 */

package id.pratama.soundofindonesia.graphic;

import id.pratama.soundofindonesia.Utils;
import id.pratama.soundofindonesia.apps.Apps_Data;

import org.andengine.engine.camera.hud.HUD;
import org.andengine.entity.primitive.Rectangle;
import org.andengine.entity.scene.Scene;
import org.andengine.entity.sprite.Sprite;
import org.andengine.opengl.texture.TextureManager;
import org.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlas;
import org.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlasTextureRegionFactory;
import org.andengine.opengl.texture.region.TextureRegion;
import org.andengine.opengl.vbo.VertexBufferObjectManager;
import org.andengine.ui.activity.BaseGameActivity;

public class Graphic_Load implements Graphic_Data, Graphic_Data_Path, Apps_Data
{
	protected BaseGameActivity		activity;
	protected Scene					m_Scene;
	protected HUD					m_Hud;

	protected BitmapTextureAtlas	tex_;
	protected TextureRegion			reg_;
	public Sprite					spr_;

	protected BitmapTextureAtlas	tex_Logo;
	protected TextureRegion			reg_Logo;
	public Sprite					spr_Logo;

	public BitmapTextureAtlas		tex_Menu_Bg;
	protected TextureRegion			reg_Menu_Bg;
	public Sprite					spr_Menu_Bg;

	protected BitmapTextureAtlas[]	tex_Menu_Daerah	= new BitmapTextureAtlas[MENU_DAERAH.length];
	protected TextureRegion[]		reg_Menu_Daerah	= new TextureRegion[MENU_DAERAH.length];
	public Sprite[]					spr_Menu_Daerah	= new Sprite[MENU_DAERAH.length];
	public Rectangle				rec_Menu_Daerah;

	// public Rectangle[] rec_Menu_Daerah = new Rectangle[MENU_DAERAH.length];

	public Graphic_Load(BaseGameActivity activity, Scene m_Scene, HUD m_Hud)
	{
		super();
		this.activity = activity;
		this.m_Scene = m_Scene;
		this.m_Hud = m_Hud;
	}

	protected TextureManager getTextMan()
	{
		return activity.getTextureManager();
	}

	protected VertexBufferObjectManager getVertex()
	{
		return activity.getVertexBufferObjectManager();
	}

	public void loadLogo()
	{
		if (tex_Logo != null)
			return;

		tex_Logo = new BitmapTextureAtlas(getTextMan(), LOGO_TEX_WIDTH, LOGO_TEX_HEIGHT, Utils.getTextureOption());
		reg_Logo = BitmapTextureAtlasTextureRegionFactory.createFromAsset(tex_Logo, activity, LOGO, 0, 0);
		tex_Logo.load();
	}

	public void loadMenuMainBg()
	{
		if (tex_Menu_Bg != null)
			return;

		tex_Menu_Bg = new BitmapTextureAtlas(getTextMan(), MENU_MAIN_BG_TEX_WIDTH, MENU_MAIN_BG_TEX_HEIGHT,
				Utils.getTextureOption());
		reg_Menu_Bg = BitmapTextureAtlasTextureRegionFactory.createFromAsset(tex_Menu_Bg, activity, MENU_MAIN_BG, 0, 0);
		tex_Menu_Bg.load();
	}

	public void loadMenuDaerah()
	{
		for (int i = 0; i < MENU_DAERAH.length; i++)
		{
			if (tex_Menu_Daerah[i] != null)
				return;

			tex_Menu_Daerah[i] = new BitmapTextureAtlas(getTextMan(), MENU_DAERAH_TEX_WIDTH, MENU_DAERAH_TEX_HEIGHT,
					Utils.getTextureOption());
			reg_Menu_Daerah[i] = BitmapTextureAtlasTextureRegionFactory.createFromAsset(tex_Menu_Daerah[i], activity,
					MENU_DAERAH[i], 0, 0);
			tex_Menu_Daerah[i].load();
		}
	}

}
